<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>vue</title>
        <!-- 引入vue文件-->
		<script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>
	</head>
	<body>
		<div id="vue">
			{{reverseMessage}}
			<input type="text" v-model="message" />
			<hr />
			{{b}}
		</div>
	</body>
	<script type="application/javascript">
		var vm=new Vue({
			el:'#vue',
			data:{
				message:'yaozhen',
				a:5
			},
			computed:{
				//属性,可直接使用,可进行复杂的计算
				reverseMessage:function(){
					return this.message.split('').reverse().join('');
				},
				b:{
					get:function(){
						return this.a+2;
					},
					set:function(val){
						this.a=val; 
					}
				}
			}
		})
		vm.b=10;//给b赋值,此时 a=10,b=12
	</script>
</html>
